package orm

import (
	"errors"
	"fmt"
	"gitee.com/dreamwood/ez"
	"sync"
)

var EzModelConfigContainer map[string]*EzModelConfig
var EzModelConfigMt sync.Mutex

func RegEzModelConfig(conf *EzModelConfig) {
	if EzModelConfigContainer == nil {
		EzModelConfigContainer = make(map[string]*EzModelConfig)
	}
	EzModelConfigMt.Lock()
	defer EzModelConfigMt.Unlock()
	EzModelConfigContainer[conf.ContainerKey] = conf
}

func GetEzModelConfig(key string) *EzModelConfig {
	if EzModelConfigContainer == nil {
		return nil
	} else {
		find, ok := EzModelConfigContainer[key]
		if !ok {
			ez.PrintError(errors.New(fmt.Sprintf("配置信息未找到%s", key)))
		}
		return find
	}
}
